<?php

/**
 * 
 * User model - Password identity is checked here
 * Note, that there is no PW-Getter - You don't need to carry that password with you everywhere you go ;).
 * @author Evan
 *
 */
class User
{
	private $id;
	private $nickname;
	private $firstname;
	private $lastname;
	private $mail;
	private $password;
	
	public function __construct($id = 0, $nickname = '', $firstname = '', $lastname = '', $mail = '', $password = '')
	{
		$this->id = intval($id);
		$this->nickname = (String) $nickname;
		$this->firstname = (String) $firstname;
		$this->lastname = (String) $lastname;
		$this->mail = (String) $mail;
		$this->password = (String) $password;
	}
	
	public function getId()
	{
		return $this->id;
	}
	
	public function getNickname()
	{
		return $this->nickname;
	}

	public function getFirstname()
	{
		return $this->firstname;
	}
	
	public function getLastname()
	{
		return $this->lastname;
	}
	
	public function getNickname()
	{
		return $this->nickname;
	}
	
	public function getMail()
	{
		return $this->mail;
	}
	
	public function setNickname($nickname)
	{
		$this->nickname = (String) $nickname;
	}
	
	public function setLastname($lastname)
	{
		$this->lastname = (String) $lastname;
	}
	
	public function setMail($mail)
	{
		$this->mail = (String) $mail;
	}

	/**
	 * Encrypt the password and sets it
	 * @param String $password
	 */
	public function setPassword($password)
	{
		$password = $this->encrypt((String) $password);
		$this->password = $password;
	}
	
	/**
	 * 
	 * Checks, if the Password is identic with the argument
	 * @param String $password
	 * @return Boolean
	 */
	public function checkPassword($password)
	{
		$password = $this->encrypt($password);
		
		if ((String) $password == $this->password)
		{
			return TRUE;
		}
		return FALSE;
	}
	
	private function encryptPassword($password)
	{
		//TODO: Encrypt password
		return $password;
	}
	
}